#pragma once
#include <ECS/ECS.h>

enum UnitAttribute : int
{
	AttributeHealth,
	AttributeSpeed,
	AttributeArmor,
	AttributeCount
};
struct DestroyableDef
{
	mtMETA_DEC;
	int attributes[AttributeCount];
	int bonuses[AttributeCount];
};

enum DamageType : int
{
	DamageNormal,
	DamageImpulse,
	DamageCount
};

struct Damage
{
	int value[DamageType::DamageCount];
};

class Destroyable : public ECS::Component
{
	mtMETA_DEC;
public:
	Destroyable();

	bool initWith(DestroyableDef* def);

	int getAttribute(UnitAttribute type) const;
	void setAttribute(UnitAttribute type, int value);

	int getBonus(UnitAttribute type) const;
	void addBonus(UnitAttribute type, int value);

	int getAttributeWithBonus(UnitAttribute type) const;

	void damage(const Damage& value);

	Signal<void()> eventDestroyed;
protected:
	int _attributes[AttributeCount];
	int _bonuses[AttributeCount];
};